1. Field of the Invention
The invention relates to a portable data storage device and to a method of dynamic memory management for the portable data storage device.
2. Description of the Related Art
A semiconductor memory, e.g., USB pen drive, is usually configured to have a data storing zone for stored data, and a reserved zone used when conducting write and erase operations and also used for bad blocks, storage of passwords, etc. For example, in the case of a 128 MB flash memory, where a block unit is 128 KB, there would be 1024 blocks, 992 of which can be allocated to the data storing zone and 32 of which can be allocated to the reserved zone. The size allocations for the data storing zone and the reserved zones are fixed beforehand and cannot be modified by the user.
The physical blocks included in the data storing zone and the reserved zone are not fixed and are not necessarily contiguous. Any block having no data stored therein or containing erased data may be assigned to the reserved zone. However, once data is written into the reserved zone, the blocks in the reserved zone that store the written data would be reassigned to the data storing zone, and other blocks in the data storing zone must be concomitantly assigned to the reserved zone in order to maintain the fixed size allocations of the data storing zone and the reserved zone.
The reserved zone includes free blocks, bad blocks, and other blocks. The number of free blocks must be non-zero to enable data writing and erasing operations. However, when the number of bad blocks in the reserved zone increases, the number of the free blocks in the reserved zone decreases accordingly. As a result, when the number of free blocks in the reserved zone eventually reaches zero, data writing and erasing operations are no longer possible, and the semiconductor memory is no longer usable.
While it is possible to fix a larger size allocation for the reserved zone to accommodate a larger number of bad blocks so as to prolong the service life of the semiconductor memory, the size of the data storing zone would be undesirably reduced.